Skip to main content

SQL injection UNION attack, finding a column containing text

1

Let's filter for Accessories.

2

Since we are proxying the traffic through Burp Suite, we can go to the Proxy > HTTP History tab to view this request.

3

Let's forward this request to the Repeater for further modification.

Once in the Repeater, let's set the category parameter to the following:

UNION SELECT NULL--

4

Since the application returns an error, we know that the number of columns in the current query is more than 1.

Let's try for two columns:

UNION SELECT NULL,NULL--

5

The application again returns an error.

Let's try for three columns:

UNION SELECT NULL,NULL,NULL--

6

The application no longer throws an error which means that there are 3 columns in the current query.

Now let's change one column to a string instead of NULL and observe the behaviour.

UNION SELECT 'test',NULL,NULL--

7

That tells us that the first column is not compatible with string data.

Let's move on to the next column.

UNION SELECT NULL,'test',NULL--

8

We can see that the second column is compatible with string data.

Now all we have to do is replace test with the string that we have to make the database retrieve.

9

We have solved the lab.

10